package hrc.tool.xml;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Element;
/**
 * 
 * @author hrc
 * @see XmlTeller
 */
public class NewStringXmlTeller extends XmlTeller {
	
	NewStringXmlTeller(String root) throws XmlException{
		this.createNewXml(root);
	}
	
	private void createNewXml(String root) throws XmlException{
		try {
        	
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            m_doc = builder.newDocument();
            m_doc.setXmlVersion("1.0");
            Element element = m_doc.createElement(root);
            m_doc.appendChild(element);        

        } catch (Exception e) {
            throw new XmlException("fail to create new xml file");
        }
	}

	@Override
	public void save() throws XmlException {
		//do nothing 
	}

}
